﻿using System;
using System.Drawing;
using System.IO;

namespace OcrAndFileApi
{
    public static class ImageExtension
    {
        public static string GetImage(string path)
        {
            Bitmap bmp = new Bitmap(path);
            using MemoryStream ms = new MemoryStream();
            bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            byte[] arr = new byte[ms.Length];
            ms.Position = 0;
            ms.Read(arr, 0, (int)ms.Length);
            ms.Close();
            return Convert.ToBase64String(arr);
        }
    }
}
